#include <iostream>
#include <vector>
#include <cstdio> 
#include <algorithm>

#define in read()
#define fi first
#define se second
#define pb push_back

using namespace std;

typedef long long ll;
typedef double db;
typedef vector < int >  vec;
typedef pair < int , int > pii;

int read() {
  int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
  while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 5e5 + 10;
const int M = 2e6 + 10;

int h[N],dfn[N],a[N],n,m,K,cnt,tim,stk[N],top,scc,mn[N],low[N],bel[N],deg[N];
bool vis[N];
struct edge { int v,nxt; } e[M];
void link(int x,int y) { e[++cnt] = (edge) { y,h[x] }; h[x] = cnt; }

void tarjan(int x) {
    dfn[x] = low[x] = ++tim; vis[x] = 1; stk[++top] = x;
    for(int i = h[x],y;i;i = e[i].nxt)
	if(!dfn[y = e[i].v]) tarjan(y),low[x] = min(low[x],low[y]);
	else if(vis[y]) low[x] = min(low[x],dfn[y]);
    if(low[x] == dfn[x]) {
	int y; ++scc;
	do {
	    y = stk[top--]; vis[y] = 0; if(!mn[scc] || a[y] < a[mn[scc]]) mn[scc] = y; bel[y] = scc;
	} while(x ^ y);
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    n = in,m = in,K = in; for(int i = 1;i <= n;i++) a[i] = in;
    for(int i = 1,u,v;i <= m;i++) u = in,v = in,link(u,v);
    for(int i = 1;i <= n;i++) if(!dfn[i]) tarjan(i);
    for(int x = 1;x <= n;x++)
	for(int i = h[x],y;i;i = e[i].nxt)
	    if(bel[x] != bel[y = e[i].v])
		++deg[bel[y]];
    for(int i = 1;i <= scc;i++) if(!deg[i]) a[mn[i]] = 0;
    sort(a + 1,a + n + 1,greater<int>());
    ll ans = 0;
    for(int i = 1;i <= K;i++) ans += a[i]; printf("%lld\n",ans); return 0;
} 
